package com.ztesoft.sca.thread;

import com.ztesoft.sca.thread.threadFactory.IvrListThreadFactory;
import com.ztesoft.sca.thread.threadPool.IvrListThreadPool;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.*;

@Component
public class IVRConvertServer {

	private static final Log logger = LogFactory.getLog(IVRConvertServer.class);

	public static final int sleepTime = 10000;

    static {
        try {
            ThreadFactory ivrListThreadFactory = new IvrListThreadFactory();
            //默认终止策略，当队列满的时候直接抛出异常
            RejectedExecutionHandler reject =  new ThreadPoolExecutor.AbortPolicy();
            ExecutorService ivrListThreadPool = new IvrListThreadPool(1,ivrListThreadFactory,reject);
            ((IvrListThreadPool) ivrListThreadPool).scheduleWithFixedDelay(new IvrListRunnable(),1L,200L,TimeUnit.SECONDS) ;
        } catch (Exception e) {
            logger.error("IvrListRunnable INIT ERROR :",e);
        }

    }
}
